using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FeetTrigger : MonoBehaviour
{
    [SerializeField] private GameObject groundObj;
    
    public void OnTriggerEnter2D(Collider2D other)
    {
        // Debug.Log("Enter");
        if (other.gameObject.layer == LayerMask.NameToLayer("Ground"))
        {
            PlayerStateMachine.Instance.SetOnGround(true);
            groundObj = other.gameObject;
        }
    }

    public void OnTriggerStay2D(Collider2D other)
    {
        if (other.gameObject.layer == LayerMask.NameToLayer("Ground"))
        {
            PlayerStateMachine.Instance.SetOnGround(true);
            groundObj = other.gameObject;
        }
    }

    public void OnTriggerExit2D(Collider2D other)
    {
        if (other.gameObject == groundObj)
        {
            PlayerStateMachine.Instance.SetOnGround(false);
            groundObj = null;
        }
    }

}
